package com.example.demo.Mappers;

import com.example.demo.beans.CheckIDCardResponse;
import com.example.demo.beans.PatientInfo;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by Administrator on 2018/3/30.
 */
@Mapper
public interface PatientInfoMapper {
    @Select("SELECT  top 1  ResultCode,ResultMsg,PatientID,Name,Sex,Age,BANLACE,IDCardNo,Birthday,CardStatus FROM AutoView_PatientInfo where CardNo=#{CardNo}  and ylklxbm='01'  order by PatientID desc")
    @Results({
            @Result(column = "ResultCode", property = "resultcode"),
            @Result(column = "ResultMsg", property = "resultmsg"),
            @Result(column = "PatientID", property = "patientid"),
            @Result(column = "Name", property = "name"),
            @Result(column = "Sex", property = "sex"),
            @Result(column = "Age", property = "age"),
            @Result(column = "BANLACE", property = "banlace"),
            @Result(column = "IDCardNo", property = "idcardno"),
            @Result(column = "Birthday", property = "birthday"),
            @Result(column = "CardStatus", property = "cardstatus")
    })
    PatientInfo selectpatientbyid(String CardNo);

    @Select("select  top 3 * from AutoView_PatientInfo")
    List<PatientInfo> selectallpatient();
@Select("select top 1 rtrim(ResultCode)ResultCode ,rtrim(ResultMsg)ResultMsg,'1'" +
  " Status,rtrim(PatientID)PatientID,rtrim(CardNo )OldCardNo " +
 "from AutoView_PatientInfo where IDCardNo=#{IDCardNo}  order by CardNo desc")
@Results({
 @Result(column = "ResultCode",property = "resultCode"),
  @Result(column = "ResultMsg",property = "resultMsg"),
  @Result(column = "Status",property = "status"),
@Result(column = "PatientID",property = "patientID"),
 @Result(column = "OldCardNo",property = "oldCardNo")
})
    CheckIDCardResponse selectcheckidcardbyID(String  IDCardNo);

}
